home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / portable / cbreak.c < prev    next >
C/C++ Source or Header  |  1993-06-18  |  2KB  |  73 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #undef    cbreak
  4.  
  5. #ifdef UNIX
  6. #define NOTLIB
  7. #include <defs.h>
  8. #include <term.h>
  9. #endif
  10.  
  11. #ifdef PDCDEBUG
  12. char *rcsid_cbreak = "$Header: C:\CURSES\portable\RCS\cbreak.c 2.1 1993/06/18 20:19:40 MH Rel MH $";
  13. #endif
  14.  
  15.  
  16.  
  17.  
  18. /*man-start*********************************************************************
  19.  
  20.   cbreak()    - set/clear cbreak mode
  21.  
  22.   X/Open Description:    cbreak() and nocbreak()
  23.      These two routines put the terminal into and out of cbreak mode.
  24.      In cbreak mode, characters typed by the user are immediately
  25.      available to the program and erase/kill character processing is
  26.      not performed.  When out of cbreak mode, the terminal driver
  27.      will buffer characters typed until a newline or carriage return
  28.      is typed.  Interrupt and flow control characters are unaffected
  29.      by this mode.  Initially the terminal may or may not need be
  30.      in cbreak mode.
  31.  
  32.   PDCurses Description:
  33.      There is no additional PDCurses functionality.
  34.  
  35.   X/Open Return Value:
  36.      The cbreak() function returns OK on success and ERR on error.
  37.  
  38.   PDCurses Errors:
  39.      No errors are defined for these functions.
  40.  
  41.   Portability:
  42.      PDCurses    int cbreak( void );
  43.      X/Open Dec '88    int cbreak( void );
  44.      BSD Curses    int cbreak( void );
  45.      SYS V Curses    int cbreak( void );
  46.  
  47. **man-end**********************************************************************/
  48.  
  49. int    cbreak(void)
  50. {
  51. #ifdef PDCDEBUG
  52.     if (trace_on) PDC_debug("cbreak() - called\n");
  53. #endif
  54.  
  55. #ifdef UNIX
  56. #ifdef USE_TERMIO
  57.     _CUR_TERM.prog_mode.c_lflag &= ~(ICANON);
  58.     _CUR_TERM.prog_mode.c_iflag &= ~(ICRNL);
  59. /*    _CUR_TERM.prog_mode.c_lflag |= ISIG;*/
  60.     _CUR_TERM.prog_mode.c_cc[VMIN] = 1;
  61.     _CUR_TERM.prog_mode.c_cc[VTIME] = 0;
  62.     ioctl(_CUR_TERM.fd, TCSETAW, &_CUR_TERM.prog_mode);
  63. #else
  64.     _CUR_TERM.prog_mode.sg_flags |= CBREAK;
  65.     ioctl(_CUR_TERM.fd, TIOCSETP, &_CUR_TERM.prog_mode);
  66. #endif
  67.  
  68. #endif
  69.  
  70.     _cursvar.cbreak = TRUE;
  71.     return( OK );
  72. }
  73.